namespace EyeOpen.Security.Data
{
	using System.ComponentModel.DataAnnotations;
	using System.Data.Entity.ModelConfiguration.Conventions;

	using EyeOpen.Data;
	using EyeOpen.Data.EntityFramework;
	using EyeOpen.Security.Domain;

	public class SecurityUnitOfWork
		: EfUnitOfWork, ISecurityUnitOfWork
	{
		public SecurityUnitOfWork()
		{
		}

		public SecurityUnitOfWork(string providerName, string connectionString)
			: base(providerName, connectionString)
		{
		}

		public IRepository<User> UserRepository
		{
			get
			{
				return
					Repository<User>();
			}
		}

		protected override void OnModelCreating(System.Data.Entity.DbModelBuilder modelBuilder)
		{
			modelBuilder.Conventions.Remove<PluralizingTableNameConvention>();
			
			modelBuilder
				.Entity<User>()
					.HasKey(x => x.Id)
						.Property(x => x.Id)
							.HasDatabaseGeneratedOption(DatabaseGeneratedOption.None);
		}
	}
}